<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:rich="http://richfaces.org/rich"
      xmlns:a4j="http://richfaces.org/a4j"
      xmlns:s="http://jboss.com/products/seam/taglib">

	<ui:composition template="/layout/template.xhtml">
		<ui:define name="navigation">
			<h:outputText value="#{messages['layout.menu.vocable.main']}" />
		</ui:define>
		<ui:define name="title">
			<h:outputText value="#{messages['layout.menu.vocable.main']}" />
		</ui:define>
		<ui:define name="body">
			<ui:include src="vocable-edit-modal.xhtml" />
			<a4j:form id="vocableGridForm">
				<rich:messages globalOnly="true"></rich:messages>
				
				<h:selectOneMenu value="#{selectedLesson}">
					<s:selectItems value="#{lessonList}" var="l" label="#{l.name}"
						noSelectionLabel="#{messages['no.selection']}"
						hideNoSelectionLabel="false"/>
					<s:convertEntity></s:convertEntity>
					<!-- <a4j:support event="onchange" reRender="vocableGridForm"></a4j:support>  -->
				</h:selectOneMenu>

				<a4j:commandButton action="#{vocablesAction.init()}"
					value="nacti" reRender="vocableEditMD"
					ajaxSingle="true" />

				<!-- BUTTON - NEW -->				
				<a4j:commandButton action="#{vocablesAction.preCreate()}"
					value="#{messages['button.new']}" reRender="vocableEditMD"
					oncomplete="Richfaces.showModalPanel('vocableEditMD');"
					disabled="#{!vocablesAction.isNewButtonEnabled()}"
					ajaxSingle="true" />

				<!-- BUTTON - EDIT -->
				<a4j:commandButton action="#{vocablesAction.preEdit()}"
					value="#{messages['button.edit']}" reRender="vocableEditMD"
					oncomplete="Richfaces.showModalPanel('vocableEditMD');"
					disabled="#{!vocablesAction.isEditButtonEnabled()}"
					ajaxSingle="true" />

				<!-- BUTTON - DELETE -->
				<a4j:commandButton action="#{vocablesAction.doDelete()}"
					value="#{messages['button.delete']}" reRender="lessonGridForm"
					oncomplete="Richfaces.showModalPanel('vocableEditMD');"
					disabled="#{!vocablesAction.isDeleteButtonEnabled()}"
					ajaxSingle="true" />

				<!-- BUTTON - OUTLOOK -->
				<a4j:commandButton action="#{vocablesAction.doOutlook()}"
					value="#{messages['button.outlook']}" reRender="xxx"
					oncomplete="Richfaces.showModalPanel('vocableEditMD');"
					disabled="#{!vocablesAction.isOutlookButtonEnabled()}"
					ajaxSingle="true" />

				<!-- BUTTON - IMPORT -->
				<a4j:commandButton action="#{vocablesAction.doImport()}"
					value="#{messages['vocable.import']}" reRender="xxx"
					oncomplete="Richfaces.showModalPanel('vocableEditMD');"
					disabled="#{!vocablesAction.isImoportButtonEnabled()}"
					ajaxSingle="true" />

				<!-- TABLE -->
				<rich:extendedDataTable id="dataTable"
					value="#{vocablesAction.model}" var="vocItem" selectionMode="single" 
					selection="#{vocablesAction.selection}">
					
					<rich:column label="#{vocItem.lessons.get(0).vocType.str1}">
						<f:facet name="header">#{vocItem.lessons.get(0).vocType.str1}</f:facet>
						<h:outputText value="#{vocItem.str1}" title="#{vocItem.str1}" />
					</rich:column>

					<rich:column label="#{vocItem.lessons.get(0).vocType.str2}">
						<f:facet name="header">#{vocItem.lessons.get(0).vocType.str2}</f:facet>
						<h:outputText value="#{vocItem.str2}" title="#{vocItem.str2}" />
					</rich:column>

					<rich:column label="#{messages['vocable.lessons']}">
						<f:facet name="header">#{messages['vocable.lessons']}</f:facet>
						<h:outputText value="#{vocItem.lessonsToStr()}" title="#{vocItem.lessonsToStr()}" />
					</rich:column>
					
					<!-- TODO display short statistic about tested vocables -->
					
					<a4j:support event="onselectionchange" ajaxSingle="true" reRender="vocableGridForm" />
				</rich:extendedDataTable>

			</a4j:form>
		</ui:define>

	</ui:composition>
</html>